package cn.soulfire.advertisement.service.impl;

import cn.soulfire.advertisement.constants.CommentConstant;
import cn.soulfire.advertisement.domain.Advertisement;
import cn.soulfire.advertisement.mapper.AdvertisementMapper;
import cn.soulfire.advertisement.service.IAdvertisementService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ma.rui.kai
 * @since 2020-10-13
 */
@Service
public class AdvertisementServiceImpl extends ServiceImpl<AdvertisementMapper, Advertisement> implements IAdvertisementService {
  @Autowired
  private AdvertisementMapper advertisementMapper;
    //修改状态
    @Override
    public void disable(Advertisement advertisement) {
        if (advertisement.getState().equals(CommentConstant.PAUSED)) {
            advertisement.setState(CommentConstant.RUNNING);
            advertisementMapper.updateById(advertisement);
        } else {
            if (advertisement.getState().equals(CommentConstant.RUNNING)) {
                advertisement.setState(CommentConstant.PAUSED);
                advertisementMapper.updateById(advertisement);
                advertisement.getState().equals(CommentConstant.RUNNING);
                advertisement.getState().equals(CommentConstant.PAUSED);
                advertisement.setState(CommentConstant.END_OF_DELIVERY);
                advertisementMapper.updateById(advertisement);
            }
        }
    }

    @Override
    public void batchDelete(List<Long> ids) {
        System.out.println(ids);
        advertisementMapper.batchDelete(ids);
    }
}
